<?php
namespace Admin\Model;
use Think\Model;

class HospitalModel extends Model {

	protected $tableName = 'hospital';

	public function index(Array $index) 
	{
		if(!is_array($index)) {
			return false;
		}
		$hospital = $this->limit($index["limit"]["firstRow"].','.$index["limit"]["listRows"])
					->select();
		return $hospital;
	}
	
	
	public function addHospital(Array $hospital)
	{
		if(!is_array($hospital)) {
			return false;
		}		
		if (!$this->create($hospital,1)) {
			return false;
		}else{
			return $this->add();
		}
	}
	
	
	public function showHospital(Array $hospital)
	{
		$hospital = $this->find($hospital["find"]);
		if(empty($hospital)) {
			return false;
		}
		return $hospital;
	}
	
	public function editHospital(Array $hospital)
	{
		if(!is_array($hospital)) {
			return false;
		}		
		if (!$this->create($hospital,2)) {
			return false;
		}else{
			return $this->save();
		}
	}
	
	public function stopHospital(Array $hospital)
	{
		if(!is_array($hospital)) {
			return false;
		}		
		if (!$this->create($hospital,2)) {
			return false;
		}else{
			return $this->save();
		}
	}
	
	public function deleteHospital(Array $hospital)
	{
		if(!is_array($hospital)) {
			return false;
		}		
		if (!$this->create($hospital,2)) {
			return false;
		}else{
			return $this->save();
		}
	}


}